/*
 * @Author: zhangweixin 
 * @Date: 2018-11-14 21:45:33 
 * @Last Modified by: zhangweixin
 * @Last Modified time: 2018-12-07 18:05:03
 */
import {
    GET_ACTIVITY_PRO_LIST_REQUEST,
		GET_ACTIVITY_PRO_LIST_SUCCESS,
		GET_ACTIVITY_PRO_LIST_FAIL
    
} from '../constants/actionTypes.js'

function getActivityListRequest(){
    return {
        type:GET_ACTIVITY_PRO_LIST_REQUEST
    }
}

function getActivityListSuccess(data){
    return{
        type:GET_ACTIVITY_PRO_LIST_SUCCESS,
        data:data
    }
}

function getActivityListFail(){
	return{
		type: GET_ACTIVITY_PRO_LIST_FAIL
	}
}

export function getActivityList(queryObj){
    return function (dispatch) {
        dispatch(getActivityListRequest());
  
        return fetch(`${ENV.ApiRoot}/activity/detail`,{
          method:'GET',
          headers: {
            'Content-Type': 'application/json'
					},
					data:queryObj
        })
            .then((response => {
                return response.json()
            }))
            .then((json) => {
                    dispatch(getActivityListSuccess(json))
                }
            ).catch(
                () => {
                    dispatch(getActivityListFail());
                }
            )
    }
}